import { get, post } from "@/request";

export interface IStaff {
  staffId: number;
  userId?: number | null;
  deptId?: number | null;
  staffName: string;
  titleId?: number | null;
  positionId?: number | null;
  joinDate?: string; // 使用字符串表示日期，前端可以格式化为需要的格式
  staffStatus?: number; // 对应后端的Byte类型
  updateTime?: string;
  updater?: string;
  avatar?: string; // 头像URL
  titleName?: string;
  titleLevel?: number;
  titleCode?: string;
  positionName?: string;
}

// 根据部门ID获取员工列表
export const fetchStaffByDeptId = (deptId: number) => {
  return get<{ data: IStaff[] }>(`/system/staff/getByDeptId/${deptId}`);
};
//查询员工列表
export const getStaffLIst = (params: any) => {
  return get<any>("/system/staff/list", { params });
};
//添加员工/system/staff/addStaff
export interface IAddStaff {
  username: string;
  password: string;
  userContact: string;
  userId?: number;
  staffName: string;
  staffPhone: string;
  deptId: number;
  positionIds: number[];
}

export const addStaff = (data: IAddStaff) => {
  return post<any>("/system/staff/addStaff", data);
};
